<?php
include("db/connect.php");
include("funcsubstr.php");
	$sql="select *  from material,cartmaterial,ordersmaterial where material.mat_id=cartmaterial.mat_id and ordersmaterial.ordermat_id=cartmaterial.ordermat_id and ordersmat_status='111' ";
	$query=mysql_query($sql);
	?>
	<table width="100%" border="1">
    <tr>
      <th width="216">รหัสการสั่งซื้อวัตถุดิบ</th>
      <th width="161">วันที่สั่งซื้อ</th>
      <th width="185">ชื่อวัตถุดิบ</th>
      <th width="148">ราคา(หน่วย)</th>
      <th width="97">จำนวน</th>
      <th width="122">ยอดรวม(บาท)</th>
     
     
      <th width="197">ยกเลิกการสั่งซื้อ</th>

    </tr>
<?php 
  while($resultmaterial=mysql_fetch_array($query)){
	   $year=substr($resultmaterial["ordersmat_date"],0,4)+543;
		$month=monthconv(substr($resultmaterial["ordersmat_date"],5,2));
		$day=substr($resultmaterial["ordersmat_date"],8,2);
  ?>
    <tr>
      <td><?php echo $resultmaterial["ordermat_id"]?></td>
      <td><?php echo $day.' '.$month.' '.$year?></td>
      <td><?php echo $resultmaterial["mat_name"]?></td>
      <td><?php echo $resultmaterial["mat_price"]."  ".$resultmaterial["mat_unit"]?></td>
      <td><?php echo $resultmaterial["mat_qty"]?></td>
      <td><?php echo number_format ($resultmaterial["mat_price"]*$resultmaterial["mat_qty"])?></td>
 
      <td><a href="report.php?orders_id=<?php echo $resultmaterial["ordermat_id"]?>&status=<?php echo $resultmaterial["ordersmat_status"]?>&mode=2" >pdf</a></td>

    </tr>
    <?php }?>
  </table>
  <script>
$(function(){
$("#frmsearch").remove();
});

</script>
	